﻿#ifndef NOTIFYMANAGER_H
#define NOTIFYMANAGER_H

#include <QObject>
#include <QQueue>

#include "qnotify.h"

/**
 * @brief  NotifyManager 拥有执行 notify 的能力，并拥有可配置最大显示数量与显示时间
 * @note   maxCount(6), 默认最大显示数量，当队列满了之后，若有显示超时项将有替补
 * @note   displayTime(10 * 1000)，单项默认最大显示时长
 * @retval None
 */
class QNotifyManager : public QObject
{
    Q_OBJECT
public:
    explicit QNotifyManager( QObject *parent = 0);

    void notify(const QString &title, const QString &body, const QString &icon, const QString url, const float windowOpacity = 1.0);
    void setMaxCount(int count);
    void setDisplayTime(int ms);

private:
    class NotifyData {
    public:
        NotifyData(const QString &icon, const QString &title, const QString &body, const QString url, const float windowOpacity = 1.0):
          icon(icon),
          title(title),
          body(body),
          url(url),
          windowOpacity(windowOpacity)
        {
        }

        QString icon;
        QString title;
        QString body;
        QString url;
        float windowOpacity;
    };

    void rearrange();
    void showNext();

    QQueue<NotifyData> dataQueue;
    QList<QNotify*> notifyList;
    int maxCount;
    int displayTime;
};

#endif // NOTIFYMANAGER_H
